<template>
  <div id="movie">
    <h3>电影名称：{{ movieName }}</h3>
    电影主角：<input ref="inputActor" type="text" />
    <button @click="getFocus()">点击获取输入框焦点</button>
    <hr />
  </div>
</template>

<script>
export default {
  name: "Movie", //组件名
  data() {
    return {
      movieName: "叶问",
    };
  },
  methods: {
    getFocus() {
      this.$nextTick(function () {
        console.log("$nextTick 延迟回调");
        this.$refs.inputActor.focus();
      });
    },
  },
};
</script>

<style>
#movie {
  color: green;
}
</style>